﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Forms;
using DevExpress.XtraBars;
using YidanSoft.FrameWork.WinForm;
using YidanSoft.FrameWork.Plugin.Manager;

namespace YidanSoft.FrameWork
{
    public interface IPlugInManager
    {
        /// <summary>
        /// 初始化插件管理器
        /// </summary>
        void InitFields();

        /// <summary>
        /// 得到或设置正在活动的插件
        /// </summary>
        IPlugIn ActivePlugIn { get; set; }

        /// <summary>
        /// 得到或设置启动插件
        /// </summary>
        List<IPlugIn> StartPlugins { get; set; }

        /// <summary>
        /// 获得已经装载的插件列表
        /// </summary>
        List<IPlugIn> PluginsLoaded { get; }

        /// <summary>
        /// 获得执行过病人改变事件的插件列表
        /// </summary>
        List<IPlugIn> PatientChangeExecuted { get; }

        /// <summary>
        /// 运行插件
        /// </summary>
        /// <param name="assemblyName"></param>
        /// <param name="startupClassName"></param>
        /// <param name="notShowMessage"></param>
        /// <returns></returns>
        IPlugIn LoadPlugIn(string assemblyName, string startupClassName, bool notShowMessage);

        /// <summary>
        /// 运行插件(菜单)
        /// </summary>
        /// <param name="menuItem"></param>
        /// <returns></returns>
        IPlugIn LoadPlugIn(IPlugInMenuInfo menuItem);

        /// <summary>
        /// 关闭插件
        /// </summary>
        /// <param name="plugin"></param>
        void ClosePlugin(IPlugIn plugin);

        /// <summary>
        /// 关闭所有已装载插件
        /// </summary>
        /// <returns></returns>
        bool ClosePluginsLoaded();

        /// <summary>
        /// 聚焦一个已经运行的插件
        /// </summary>
        /// <param name="plugin"></param>
        void FocusLoadedPlugIn(IPlugIn plugin);

        /// <summary>
        /// 注册所有插件
        /// </summary>
        void RegisterExternalPlugins();

        /// <summary>
        /// 通过给定的文件加载控件菜单
        /// </summary>
        /// <param name="pluginFilePath"></param>
        void RegisterPlugins(string pluginFilePath);

        /// <summary>
        /// 注销所有插件
        /// </summary>
        void UnRegisterAllPlugins();

        /// <summary>
        /// 装载程序集
        /// </summary>
        /// <param name="assemblyName"></param>
        /// <param name="assemblyClassName"></param>
        /// <param name="loadFuncName"></param>
        /// <param name="param"></param>
        void LoadAnotherAssembly(string assemblyName, string assemblyClassName, string loadFuncName, object[] param);

        int PlugInIndexInList(string assemblyName, string assemblyClassName, System.Collections.Generic.List<IPlugIn> plugins);
        int PluginIndexInLoaded(string assemblyName, string assemblyClassName);

        PlugInLoadConfiguration PlugInLoadConfig { get; }

        Collection<PlugInConfiguration> PluginMenu { get;set; }

        /// <summary>
        /// 所有插件已经装载
        /// </summary>
        event EventHandler<EventArgs> AllPluginRegistered;

        //DockingHelper DockingHelper { get; }

        //IDockingForm DockingOperationForm { get; set; }
    }
}